home *** CD-ROM | disk | FTP | other *** search
Wrap
Text File | 2002-10-03 | 42.8 KB | 1,187 lines
RRRRPPPPCCCC((((3333RRRR)))) RRRRPPPPCCCC((((3333RRRR)))) NNNNAAAAMMMMEEEE rpc - Remote Procedure Call (RPC) library routines SSSSYYYYNNNNOOOOPPPPSSSSIIIISSSS AAAANNNNDDDD DDDDEEEESSSSCCCCRRRRIIIIPPPPTTTTIIIIOOOONNNN These routines allow C programs to make procedure calls on other machines across the network. First, the client calls a procedure to send a data packet to the server. Upon receipt of the packet, the server calls a dispatch routine to perform the requested service, and then sends back a reply. Finally, the procedure call returns to the client. #include <rpc/rpc.h> void auth_destroy(AUTH *auth) A macro that destroys the authentication information associated with _a_u_t_h. Destruction usually involves deallocation of private data structures. The use of _a_u_t_h is undefined after calling _a_u_t_h__d_e_s_t_r_o_y(). AUTH * authnone_create(void) Create and returns an RPC authentication handle that passes nonusable authentication information with each remote procedure call. This is the default authentication used by RPC. AUTH * authunix_create(const char *host, int uid, int gid, int len, int *aup_gids) Create and return an RPC authentication handle that contains UNIX authentication information. The parameter _h_o_s_t is the name of the machine on which the information was created; _u_i_d is the user's user ID; _g_i_d is the user's current group ID; _l_e_n and _a_u_p__g_i_d_s refer to a counted array of groups to which the user belongs. It is easy to impersonate a user. AUTH * authunix_create_default(void) Call _a_u_t_h_u_n_i_x__c_r_e_a_t_e() with the appropriate parameters. PPPPaaaaggggeeee 1111 RRRRPPPPCCCC((((3333RRRR)))) RRRRPPPPCCCC((((3333RRRR)))) enum clnt_stat callrpc(const char *host, u_long prognum, u_long versnum, u_long procnum, xdrproc_t inproc, void *in, xdrproc_t outproc, void *out) Call the remote procedure associated with _p_r_o_g_n_u_m, _v_e_r_s_n_u_m, and _p_r_o_c_n_u_m on the machine, _h_o_s_t. The parameter _i_n is the address of the procedure's argument(s), and _o_u_t is the address of where to place the result(s); _i_n_p_r_o_c is used to encode the procedure's parameters, and _o_u_t_p_r_o_c is used to decode the procedure's results. This routine returns 0 if it succeeds, or the value of _e_n_u_m _c_l_n_t__s_t_a_t cast to an integer if it fails. The routine _c_l_n_t__p_e_r_r_n_o() is handy for translating failure statuses into messages. Warning: calling remote procedures with this routine uses UDP/IP as a transport; see _c_l_n_t_u_d_p__c_r_e_a_t_e() for restrictions. You do not have control of timeouts or authentication using this routine. enum clnt_stat clnt_broadcast(u_long prognum, u_long versnum, u_long procnum, xdrproc_t inproc, void *in, xdrproc_t outproc, void *out, bool_t (*eachresult)(void *, struct sockaddr_in *)) Like _c_a_l_l_r_p_c(), except the call message is broadcast to all locally connected broadcast nets. Each time it receives a response, this routine calls _e_a_c_h_r_e_s_u_l_t(), whose form is: bool_t eachresult(void *out, struct sockaddr_in *addr) where _o_u_t is the same as _o_u_t passed to _c_l_n_t__b_r_o_a_d_c_a_s_t(), except that the remote procedure's output is decoded there; _a_d_d_r points to the address of the machine that sent the results. If _e_a_c_h_r_e_s_u_l_t() returns 0, _c_l_n_t__b_r_o_a_d_c_a_s_t() waits for more replies; otherwise it returns with appropriate status. Initially, it waits 4 seconds for a response before retrying. The next wait interval is doubled until it reaches a total wait time of 45 seconds. See also _c_l_n_t__s_e_t_b_r_o_a_d_c_a_s_t_b_a_c_k_o_f_f(). Warning: broadcast sockets are limited in size to the maximum transfer unit of the data link. For ethernet, this value is 1500 bytes. For FDDI, this value is 4532 bytes. PPPPaaaaggggeeee 2222 RRRRPPPPCCCC((((3333RRRR)))) RRRRPPPPCCCC((((3333RRRR)))) enum clnt_stat clnt_broadcast_exp(u_long prognum, u_long versnum, u_long procnum, xdrproc_t inproc, void *in, xdrproc_t outproc, void *out, bool_t (*eachresult)(void *, struct sockaddr_in *), int inittime, waittime) Like _c_l_n_t__b_r_o_a_d_c_a_s_t(), except you can specify the initial and total wait time. See also _c_l_n_t__s_e_t_b_r_o_a_d_c_a_s_t_b_a_c_k_o_f_f(). enum clnt_stat clnt_call(CLIENT *clnt, u_long procnum, xdrproc_t inproc, void *in, xdrproc_t outproc, void *out, struct timeval tout) A macro that calls the remote procedure _p_r_o_c_n_u_m associated with the client handle, _c_l_n_t, which is obtained with an RPC client creation routine such as _c_l_n_t_u_d_p__c_r_e_a_t_e(). The parameter _i_n is the address of the procedure's argument(s), and _o_u_t is the address of where to place the result(s); _i_n_p_r_o_c is used to encode the procedure's parameters, and _o_u_t_p_r_o_c is used to decode the procedure's results; _t_o_u_t is the time allowed for results to come back. void clnt_control(CLIENT *clnt, u_int request, void *info) A macro used to change or retrieve various information about a client object. _r_e_q_u_e_s_t indicates the type of operation, and _i_n_f_o is a pointer to the information. For both UDP and TCP, the supported values of _r_e_q_u_e_s_t and their argument types and what they do are: CLSET_TIMEOUT struct timeval set total timeout CLGET_TIMEOUT struct timeval get total timeout CLGET_SERVER_ADDR struct sockaddr_in get server's address CLGET_FD int get connection's file descriptor CLSET_FD_CLOSE (ignored) let clnt_destroy close fd CLSET_FD_NCLOSE (ignored) don't let clnt_destroy close fd Note: if you set the timeout using _c_l_n_t__c_o_n_t_r_o_l(), the timeout parameter passed to _c_l_n_t__c_a_l_l() will be ignored in all future calls. The following operations are valid for UDP only: CLSET_RETRY_TIMEOUT struct timeval set the retry timeout PPPPaaaaggggeeee 3333 RRRRPPPPCCCC((((3333RRRR)))) RRRRPPPPCCCC((((3333RRRR)))) CLGET_RETRY_TIMEOUT struct timeval get the retry timeout The retry timeout is the time that UDP RPC waits for the server to reply before retransmitting the request. The following operations are valid for TCP only: CLSET_EINTR_RETURN bool_t set param to 1 to return on EINTR CLGET_EINTR_RETURN bool_t get return on EINTR flag CLIENT * clnt_create(const char *host, u_long prog, u_long vers, const char *proto) Generic client creation routine. _h_o_s_t identifies the name of the remote host where the server is located. _p_r_o_t_o indicates which kind of transport protocol to use. The currently supported values for this field are udp and tcp. Default timeouts are set, but can be modified using _c_l_n_t__c_o_n_t_r_o_l(). Warning: Using UDP has its shortcomings. Since UDP-based RPC messages can only hold up to 8 kilobytes of encoded data, this transport cannot be used for procedures that take large arguments or return huge results. CLIENT * clnt_create_vers(const char *host, u_long prog, u_long *vers_out, u_long vers_low, u_long vers_high, const char *proto) Generic client creation with version checking. The server must support a version between _v_e_r_s__l_o_w and _v_e_r_s__h_i_g_h, inclusive. An error results if this can not be done. The value of _v_e_r_s__o_u_t is set to the highest server-supported value. void clnt_destroy(CLIENT *clnt) A macro that destroys the client's RPC handle. Destruction usually involves deallocation of private data structures, including _c_l_n_t itself. Use of _c_l_n_t is undefined after calling _c_l_n_t__d_e_s_t_r_o_y(). If the RPC library opened the associated socket, it will close it also. Otherwise, the socket remains open and it is the responsibility of the caller to close the socket. Use the CLGET_FD request to _c_l_n_t__c_o_n_t_r_o_l() to obtain the descriptor or the CLSET_FD_CLOSE request to have _c_l_n_t__d_e_s_t_r_o_y() close it. PPPPaaaaggggeeee 4444 RRRRPPPPCCCC((((3333RRRR)))) RRRRPPPPCCCC((((3333RRRR)))) bool_t clnt_freeres(CLIENT *clnt, xdrproc_t outproc, void *out) A macro that frees any data allocated by the RPC/XDR system when it decoded the results of an RPC call. The parameter _o_u_t is the address of the results, and _o_u_t_p_r_o_c is the XDR routine describing the results. This routine returns 1 if the results were successfully freed, and 0 otherwise. void clnt_geterr(CLIENT *clnt, struct rpc_err *errp) A macro that copies the error structure out of the client handle to the structure at address _e_r_r_p. void clnt_pcreateerror(const char *s) Print a message to standard error indicating why a client RPC handle could not be created. The message is prepended with string _s and a colon. Used when a _c_l_n_t__c_r_e_a_t_e(), _c_l_n_t_r_a_w__c_r_e_a_t_e(), _c_l_n_t_t_c_p__c_r_e_a_t_e(), or _c_l_n_t_u_d_p__c_r_e_a_t_e() call fails. void clnt_perrno(enum clnt_stat stat) Print a message to standard error corresponding to the condition indicated by _s_t_a_t. Used after _c_a_l_l_r_p_c(). void clnt_perror(CLIENT *clnt, const char *s) Print a message to standard error indicating why an RPC call failed; _c_l_n_t is the handle used to do the call. The message is prepended with string _s and a colon. Used after _c_l_n_t__c_a_l_l(). void clnt_setbroadcastbackoff(void (*first)(struct timeval *tv), int (*next)(struct timeval *tv)) PPPPaaaaggggeeee 5555 RRRRPPPPCCCC((((3333RRRR)))) RRRRPPPPCCCC((((3333RRRR)))) Set the timeout backoff iterator for clnt_broadcast(). The initial timeout is stored in *_t_v by _f_i_r_s_t(). Subsequent timeouts are computed in *_t_v by _n_e_x_t() , which returns 1 until a backoff limit is reached, and thereafter returns 0. char * clnt_spcreateerror(const char *s) Like _c_l_n_t__p_c_r_e_a_t_e_e_r_r_o_r(), except that it returns a string instead of printing to the standard error. Bugs: returns a pointer to static data that is overwritten on each call. char * clnt_sperrno(enum clnt_stat stat) Take the same arguments as _c_l_n_t__p_e_r_r_n_o(), but instead of sending a message to the standard error indicating why an RPC call failed, return a pointer to a string which contains the message. The string ends with a NEWLINE. _c_l_n_t__s_p_e_r_r_n_o() is used instead of _c_l_n_t__p_e_r_r_n_o() if the program does not have a standard error (a server program quite likely does not), or if the programmer does not want the message to be output with _p_r_i_n_t_f, or if a message format different than that supported by _c_l_n_t__p_e_r_r_n_o() is to be used. Note: unlike _c_l_n_t__s_p_e_r_r_o_r() and _c_l_n_t__s_p_c_r_e_a_t_e_r_r_o_r(), _c_l_n_t__s_p_e_r_r_n_o() returns a pointer to static data, but the result will not get overwritten on each call. char * clnt_sperror(CLIENT *clnt, const char *s) Like _c_l_n_t__p_e_r_r_o_r(), except that (like _c_l_n_t__s_p_e_r_r_n_o()) it returns a string instead of printing to standard error. Bugs: returns a pointer to static data that is overwritten on each call. void clnt_syslog(CLIENT *clnt, const char *s) PPPPaaaaggggeeee 6666 RRRRPPPPCCCC((((3333RRRR)))) RRRRPPPPCCCC((((3333RRRR)))) Logs a LOG_ERR error to _s_y_s_l_o_g(3) indicating why an RPC call failed; _c_l_n_t is the handle used to do the call. The message is prepended with string s and a colon. CLIENT * clntraw_create(u_long prognum, u_long versnum) This routine creates a toy RPC client for the remote program _p_r_o_g_n_u_m, version _v_e_r_s_n_u_m. The transport used to pass messages to the service is actually a buffer within the process's address space, so the corresponding RPC server should live in the same address space; see _s_v_c_r_a_w__c_r_e_a_t_e(). This allows simulation of RPC and acquisition of RPC overheads, such as round trip times, without any kernel interference. This routine returns NULL if it fails. CLIENT * clnttcp_create(struct sockaddr_in *addr, u_long prognum, u_long versnum, int *sockp, u_int sendsize, u_int recvsize) This routine creates an RPC client for the remote program _p_r_o_g_n_u_m, version _v_e_r_s_n_u_m; the client uses TCP/IP as a transport. The remote program is located at Internet address *_a_d_d_r. If _a_d_d_r->_s_i_n__p_o_r_t is 0, then it is set to the actual port that the remote program is listening on (the remote _p_o_r_t_m_a_p service is consulted for this information). The parameter _s_o_c_k_p is a socket; if it is RRRRPPPPCCCC____AAAANNNNYYYYSSSSOOOOCCCCKKKK, then this routine opens a new one and sets _s_o_c_k_p. Since TCP-based RPC uses buffered I/O , the user may specify the size of the send and receive buffers with the parameters _s_e_n_d_s_i_z_e and _r_e_c_v_s_i_z_e; values of 0 choose suitable defaults. This routine returns NULL if it fails. CLIENT * clntudp_create(struct sockaddr_in *addr, u_long prognum, u_long versnum, struct timeval wait, int *sockp) This routine creates an RPC client for the remote program _p_r_o_g_n_u_m, version _v_e_r_s_n_u_m; the client uses use UDP/IP as a transport. The remote program is located at Internet address _a_d_d_r. If - _a_d_d_r->_s_i_n__p_o_r_t is 0, then it is set to actual port that the remote program is listening on (the remote _p_o_r_t_m_a_p service is consulted for this information). The parameter _s_o_c_k_p is a socket; if it is RRRRPPPPCCCC____AAAANNNNYYYYSSSSOOOOCCCCKKKK, then this routine opens a new one and sets _s_o_c_k_p. The UDP transport resends the call message in intervals of _w_a_i_t time until a response is received or until the call times out. The total PPPPaaaaggggeeee 7777 RRRRPPPPCCCC((((3333RRRR)))) RRRRPPPPCCCC((((3333RRRR)))) time for the call to time out is specified by _c_l_n_t__c_a_l_l(). Warning: since UDP-based RPC messages can only hold up to 8 kilobytes of encoded data, this transport cannot be used for procedures that take large arguments or return huge results. CLIENT * clntudp_bufcreate(struct sockaddr_in *addr, u_long prognum, u_long versnum, struct timeval wait, int *sockp, u_int sendsize, u_int recvsize) Like _c_l_n_t_u_d_p__c_r_e_a_t_e(), except this call allows the user to specify the maximum packet size for sending and receiving UDP-based RPC messages. void get_myaddress(struct sockaddr_in *addr) Stuff the machine's IP address into *_a_d_d_r, without consulting the library routines that deal with /_e_t_c/_h_o_s_t_s. The port number is always set to _h_t_o_n_s(PPPPMMMMAAAAPPPPPPPPOOOORRRRTTTT). struct pmaplist * pmap_getmaps(addr) struct sockaddr_in *addr; A user interface to the _p_o_r_t_m_a_p service, which returns a list of the current RPC program-to-port mappings on the host located at IP address *_a_d_d_r. This routine can return NULL. The command `rrrrppppcccciiiinnnnffffoooo ----pppp' uses this routine. u_short pmap_getport(struct sockaddr_in *addr, u_long prognum, u_long versnum, u_int protocol) A user interface to the _p_o_r_t_m_a_p service, which returns the port number on which waits a service that supports program number _p_r_o_g_n_u_m, version _v_e_r_s_n_u_m, and speaks the transport protocol associated with _p_r_o_t_o_c_o_l. The value of _p_r_o_t_o_c_o_l is most likely IIIIPPPPPPPPRRRROOOOTTTTOOOO____UUUUDDDDPPPP or IIIIPPPPPPPPRRRROOOOTTTTOOOO____TTTTCCCCPPPP. A return value of 0 means that the mapping does not exist or that the RPC system failured to contact the remote _p_o_r_t_m_a_p service. In the latter case, the global variable _r_p_c__c_r_e_a_t_e_e_r_r() contains the RPC status. PPPPaaaaggggeeee 8888 RRRRPPPPCCCC((((3333RRRR)))) RRRRPPPPCCCC((((3333RRRR)))) enum clnt_stat pmap_rmtcall(struct sockaddr_in *addr, u_long prognum, u_long versnum, u_long procnum, xdrproc_t inproc, void *in, xdrproc_t outproc, void *out, struct timeval tout, u_long *portp) A user interface to the _p_o_r_t_m_a_p service, which instructs _p_o_r_t_m_a_p on the host at IP address *_a_d_d_r to make an RPC call on your behalf to a procedure on that host. The parameter *_p_o_r_t_p will be modified to the program's port number if the procedure succeeds. The definitions of other parameters are discussed in _c_a_l_l_r_p_c() and _c_l_n_t__c_a_l_l(). This procedure should be used for a ping and nothing else. See also _c_l_n_t__b_r_o_a_d_c_a_s_t(). _p_m_a_p__s_e_t_t_i_m_e_o_u_t_s(), and _p_m_a_p__s_e_t_r_m_t_c_a_l_l_t_i_m_e_o_u_t(). bool_t pmap_set(u_long prognum, u_long versnum, u_long protocol, u_short port) A user interface to the _p_o_r_t_m_a_p service, which establishes a mapping between the triple [_p_r_o_g_n_u_m, _v_e_r_s_n_u_m, _p_r_o_t_o_c_o_l] and _p_o_r_t on the machine's _p_o_r_t_m_a_p service. The value of _p_r_o_t_o_c_o_l is most likely IIIIPPPPPPPPRRRROOOOTTTTOOOO____UUUUDDDDPPPP or IIIIPPPPPPPPRRRROOOOTTTTOOOO____TTTTCCCCPPPP. This routine returns 1 if it succeeds, 0 otherwise. Automatically done by _s_v_c__r_e_g_i_s_t_e_r(). void pmap_setrmtcalltimeout(struct timeval intertry) Set the retry timeout for _p_m_a_p__r_m_t_c_a_l_l(). Note that the total timeout per call is an argument to _p_m_a_p__r_m_t_c_a_l_l(). void pmap_settimeouts(struct timeval intertry, struct timeval percall) Set the retry and total timeouts for RPCs to the portmapper. These timeouts are used explicitly by _p_m_a_p__s_e_t() and _p_m_a_p__g_e_t_p_o_r_t(), and implicitly by _c_l_n_t*__c_r_e_a_t_e(). bool_t pmap_unset(u_long prognum, u_long versnum) PPPPaaaaggggeeee 9999 RRRRPPPPCCCC((((3333RRRR)))) RRRRPPPPCCCC((((3333RRRR)))) A user interface to the _p_o_r_t_m_a_p service, which destroys all mapping between the triple [_p_r_o_g_n_u_m, _v_e_r_s_n_u_m, *] and _p_o_r_t_s on the machine's _p_o_r_t_m_a_p service. This routine returns 1 if it succeeds, 0 otherwise. int registerrpc(u_long prognum, u_long versnum, u_long procnum, void *(*procname)(void *), xdrproc_t inproc, xdrproc_t outproc) Register procedure _p_r_o_c_n_a_m_e with the RPC service package. If a request arrives for program _p_r_o_g_n_u_m, version _v_e_r_s_n_u_m, and procedure _p_r_o_c_n_u_m, _p_r_o_c_n_a_m_e is called with a pointer to its parameter(s); _p_r_o_g_n_a_m_e should return a pointer to its static result(s); _i_n_p_r_o_c is used to decode the parameters while _o_u_t_p_r_o_c is used to encode the results. This routine returns 0 if the registration succeeded, -1 otherwise. Warning: remote procedures registered in this form are accessed using the UDP/IP transport; see _s_v_c_u_d_p__c_r_e_a_t_e() for restrictions. struct rpc_createerr rpc_createerr A global variable whose value is set by any RPC client creation routine that does not succeed. Use the routine _c_l_n_t__p_c_r_e_a_t_e_e_r_r_o_r() to print the reason why. void _rpc_errorhandler(int priority, const char *format, ...) Called by the RPC library routines to print an error message to _s_t_d_e_r_r or to _s_y_s_l_o_g(3), if _o_p_e_n_l_o_g(3) was called. _p_r_i_o_r_i_t_y values are defined in <_s_y_s_l_o_g._h>. _f_o_r_m_a_t is printf-like format string. See comments in <_r_p_c/_e_r_r_o_r_h_a_n_d_l_e_r._h> for details on defining your own version for more sophisticated error handling. bool_t rpc_control(int op, void info) This RPC library routine exists in IRIX libc but is not yet fully implemented. It may be fully implemented in a future version of IRIX. Until then, use of this routine by applications is unsupported. PPPPaaaaggggeeee 11110000 RRRRPPPPCCCC((((3333RRRR)))) RRRRPPPPCCCC((((3333RRRR)))) If a third-party library uses this function to enable multi-threaded RPC, you should use the following code to disable the feature. This code should run after the third-party library's call and before any calls to _ssss_vvvv_cccc______rrrr_uuuu_nnnn, _ssss_vvvv_cccc______gggg_eeee_tttt_rrrr_eeee_qqqq or _ssss_vvvv_cccc______gggg_eeee_tttt_rrrr_eeee_qqqq_ssss_eeee_tttt. int mt_mode = RPC_SVC_MT_NONE; rpc_control(RPC_SVC_MTMODE_SET, &mt_mode); void svc_destroy(SVCXPRT *xprt) A macro that destroys the RPC service transport handle, _x_p_r_t. Destruction usually involves deallocation of private data structures, including _x_p_r_t itself. Use of _x_p_r_t is undefined after calling this routine. fd_set svc_fdset; A global variable reflecting the RPC service side's read file descriptor bit mask; it is suitable as a parameter to the _s_e_l_e_c_t(2) system call. This is only of interest if a service implementor does not call _s_v_c__r_u_n(), in order to do asynchronous event processing, for example. This variable is read-only (do not pass its address to _s_e_l_e_c_t!), yet it may change after calls to _s_v_c__g_e_t_r_e_q_s_e_t() or any creation routines. int svc_fds Similar to _s_v_c__f_d_s_e_t, but limited to 32 descriptors. This interface is obsoleted by _s_v_c__f_d_s_e_t. bool_t svc_freeargs(SVCXPRT *xprt, xdrproc_t inproc, void *in) A macro that frees any data allocated by the RPC/XDR system when it decoded the arguments to a service procedure using _s_v_c__g_e_t_a_r_g_s(). This routine returns 1 if the results were successfully freed, and 0 otherwise. PPPPaaaaggggeeee 11111111 RRRRPPPPCCCC((((3333RRRR)))) RRRRPPPPCCCC((((3333RRRR)))) bool_t svc_getargs(SVCXPRT *xprt, xdrproc_t inproc, void *in) A macro that decodes the arguments of an RPC request associated with the RPC service transport handle, _x_p_r_t. The parameter _i_n is the address where the arguments will be placed; _i_n_p_r_o_c is the XDR routine used to decode the arguments. This routine returns 1 if decoding succeeds, and 0 otherwise. Only after this routine is called can the server call _f_o_r_k(2) to create a child process to handle the request. struct sockaddr_in * svc_getcaller(SVCXPRT *xprt) The approved way of getting the network address of the caller of a procedure associated with the RPC service transport handle, _x_p_r_t. void svc_getreq(int rdfds) This routine is provided for compatibility with old code. Use _s_v_c__g_e_t_r_e_q_s_e_t () when developing new code. void svc_getreqset(fd_set *rdfds) This routine is only of interest if a service implementor does not call _s_v_c__r_u_n(), but instead implements custom asynchronous event processing. It is called when the _s_e_l_e_c_t(2) system call has determined that an RPC request has arrived on some RPC _s_o_c_k_e_t(_s); _r_d_f_d_s is the resultant read file descriptor bit mask. The routine returns when all sockets associated with the value of _r_d_f_d_s have been serviced. bool_t svc_register(SVCXPRT *xprt, u_long prognum, u_long versnum, void (*dispatch)(struct svc_req *,SVCXPRT *), int protocol) Associates _p_r_o_g_n_u_m and _v_e_r_s_n_u_m with the service dispatch procedure, _d_i_s_p_a_t_c_h. If _p_r_o_t_o_c_o_l is 0, the service is not registered with the _p_o_r_t_m_a_p service. If _p_r_o_t_o_c_o_l is non-zero, then a mapping of the PPPPaaaaggggeeee 11112222 RRRRPPPPCCCC((((3333RRRR)))) RRRRPPPPCCCC((((3333RRRR)))) triple [_p_r_o_g_n_u_m, _v_e_r_s_n_u_m, _p_r_o_t_o_c_o_l] to _x_p_r_t->_x_p__p_o_r_t is established with the local _p_o_r_t_m_a_p service (generally _p_r_o_t_o_c_o_l is 0, IIIIPPPPPPPPRRRROOOOTTTTOOOO____UUUUDDDDPPPP or IIIIPPPPPPPPRRRROOOOTTTTOOOO____TTTTCCCCPPPP ). The procedure _d_i_s_p_a_t_c_h has the following form: void dispatch(struct svc_req *request, SVCXPRT *xprt) The _s_v_c__r_e_g_i_s_t_e_r() routine returns 1 if it succeeds, and 0 otherwise. void svc_run(void) This routine never returns. It waits for RPC requests to arrive, and calls the appropriate service procedure using _s_v_c__g_e_t_r_e_q() when one arrives. This procedure is usually waiting for a _s_e_l_e_c_t() system call to return. bool_t svc_sendreply(SVCXPRT *xprt, xdrproc_t outproc, void *out) Called by an RPC service's dispatch routine to send the results of a remote procedure call. The parameter _x_p_r_t is the request's associated transport handle; _o_u_t_p_r_o_c is the XDR routine which is used to encode the results; and _o_u_t is the address of the results. This routine returns 1 if it succeeds, 0 otherwise. void svc_unregister(u_long prognum, u_long versnum) Remove all mapping of the double [_p_r_o_g_n_u_m, _v_e_r_s_n_u_m] to dispatch routines, and of the triple [_p_r_o_g_n_u_m, _v_e_r_s_n_u_m, *] to port number. void svc_versquiet(SVCXPRT *xprt) Tell the RPC library to not complain (send no reply message at all) about version errors to the client. This is useful when revving broadcast protocols that sit on a fixed address. TCP services ignore this flag. PPPPaaaaggggeeee 11113333 RRRRPPPPCCCC((((3333RRRR)))) RRRRPPPPCCCC((((3333RRRR)))) void svcerr_auth(SVCXPRT *xprt, enum auth_stat why) Called by a service dispatch routine that refuses to perform a remote procedure call due to an authentication error. void svcerr_decode(SVCXPRT *xprt) Called by a service dispatch routine that cannot successfully decode its parameters. See also _s_v_c__g_e_t_a_r_g_s(). void svcerr_noproc(SVCXPRT *xprt) Called by a service dispatch routine that does not implement the procedure number that the caller requests. void svcerr_noprog(SVCXPRT *xprt) Called when the desired program is not registered with the RPC package. Service implementors usually do not need this routine. void svcerr_progvers(SVCXPRT *xprt, u_long low_vers, u_long high_vers) Called when the desired version of a program is not registered with the RPC package. Service implementors usually do not need this routine. void svcerr_systemerr(SVCXPRT *xprt) Called by a service dispatch routine when it detects a system error not covered by any particular protocol. For example, if a service can no longer allocate storage, it may call this routine. PPPPaaaaggggeeee 11114444 RRRRPPPPCCCC((((3333RRRR)))) RRRRPPPPCCCC((((3333RRRR)))) void svcerr_weakauth(SVCXPRT *xprt) Called by a service dispatch routine that refuses to perform a remote procedure call due to insufficient authentication parameters. The routine calls _s_v_c_e_r_r__a_u_t_h(_x_p_r_t, _A_U_T_H__T_O_O_W_E_A_K). SVCXPRT * svcraw_create(void) This routine creates a toy RPC service transport, to which it returns a pointer. The transport is really a buffer within the process's address space, so the corresponding RPC client should live in the same address space; see _c_l_n_t_r_a_w__c_r_e_a_t_e(). This routine allows simulation of RPC and acquisition of RPC overheads (such as round trip times), without any kernel interference. This routine returns NULL if it fails. SVCXPRT * svctcp_create(int sock, u_int sendsize, u_int recvsize) This routine creates a TCP/IP-based RPC service transport, to which it returns a pointer. The transport is associated with the socket _s_o_c_k, which may be RRRRPPPPCCCC____AAAANNNNYYYYSSSSOOOOCCCCKKKK, in which case a new socket is created. If the socket is not bound to a local TCP port, then this routine binds it to an arbitrary port. Upon completion, - _x_p_r_t->_x_p__s_o_c_k is the transport's socket descriptor, and - _x_p_r_t->_x_p__p_o_r_t is the transport's port number. This routine returns NULL if it fails. Since TCP-based RPC uses buffered I/O, users may specify the size of the _s_e_n_d and _r_e_c_e_i_v_e buffers; values of 0 choose suitable defaults. SVCXPRT * svcfd_create(int fd, u_int sendsize, u_int recvsize) Create a service on top of any open descriptor. Typically, this descriptor is a connected socket for a stream protocol such as TCP. _s_e_n_d_s_i_z_e and _r_e_c_v_s_i_z_e indicate sizes for the send and receive buffers. If they are zero, a reasonable default is chosen. SVCXPRT * svcudp_bufcreate(int sock, u_int sendsize, u_int recvsize) PPPPaaaaggggeeee 11115555 RRRRPPPPCCCC((((3333RRRR)))) RRRRPPPPCCCC((((3333RRRR)))) This routine creates a UDP/IP-based RPC service transport, to which it returns a pointer. The transport is associated with the socket _s_o_c_k, which may be RRRRPPPPCCCC____AAAANNNNYYYYSSSSOOOOCCCCKKKK, in which case a new socket is created. If the socket is not bound to a local UDP port, then this routine binds it to an arbitrary port. Upon completion, - _x_p_r_t->_x_p__s_o_c_k is the transport's socket descriptor, and - _x_p_r_t->_x_p__p_o_r_t is the transport's port number. This routine returns NULL if it fails. This allows the user to specify the maximun packet size for sending and receiving UDP-based RPC messages. SVCXPRT * svcudp_create(int sock) This routine creates a UDP/IP-based RPC service transport, to which it returns a pointer. The transport is associated with the socket _s_o_c_k, which may be RRRRPPPPCCCC____AAAANNNNYYYYSSSSOOOOCCCCKKKK, in which case a new socket is created. If the socket is not bound to a local UDP port, then this routine binds it to an arbitrary port. Upon completion, _x_p_r_t->_x_p__s_o_c_k is the transport's socket number, and _x_p_r_t->_x_p__p_o_r_t is the transport's port number. This routine returns NULL if it fails. Warning: since UDP-based RPC messages can only hold up to 8 kilobytes of encoded data, this transport cannot be used for procedures that take large arguments or return huge results. bool_t xdr_accepted_reply(XDR *xdrs, struct accepted_reply *ar) Used for encoding RPC reply messages. This routine is useful for users who wish to generate RPC-style messages without using the RPC package. bool_t xdr_authunix_parms(XDR *xdrs, struct authunix_parms *aupp) Used for describing UNIX credentials. This routine is useful for users who wish to generate these credentials without using the RPC authentication package. bool_t xdr_callhdr(XDR *xdrs, struct rpc_msg *chdr) PPPPaaaaggggeeee 11116666 RRRRPPPPCCCC((((3333RRRR)))) RRRRPPPPCCCC((((3333RRRR)))) Used for describing RPC call header messages. This routine is useful for users who wish to generate RPC-style messages without using the RPC package. bool_t xdr_callmsg(XDR *xdrs, struct rpc_msg *cmsg) Used for describing RPC call messages. This routine is useful for users who wish to generate RPC-style messages without using the RPC package. bool_t xdr_opaque_auth(XDR *xdrs, struct opaque_auth *ap) Used for describing RPC authentication information messages. This routine is useful for users who wish to generate RPC-style messages without using the RPC package. bool_t xdr_pmap(XDR *xdrs, struct pmap *regs) Used for describing parameters to various _p_o_r_t_m_a_p procedures, externally. This routine is useful for users who wish to generate these parameters without using the _p_m_a_p interface. bool_t xdr_pmaplist(XDR *xdrs, struct pmaplist **rp) Used for describing a list of port mappings, externally. This routine is useful for users who wish to generate these parameters without using the _p_m_a_p interface. bool_t xdr_rejected_reply(XDR *xdrs, struct rejected_reply *rr) Used for describing RPC reply messages. This routine is useful for users who wish to generate RPC-style messages without using the RPC package. PPPPaaaaggggeeee 11117777 RRRRPPPPCCCC((((3333RRRR)))) RRRRPPPPCCCC((((3333RRRR)))) bool_t xdr_replymsg(XDR *xdrs, struct rpc_msg *rmsg) Used for describing RPC reply messages. This routine is useful for users who wish to generate RPC style messages without using the RPC package. void xprt_register(SVCXPRT *xprt) After RPC service transport handles are created, they should register themselves with the RPC service package. This routine modifies the global variable _s_v_c__f_d_s. Service implementors usually do not need this routine. void xprt_unregister(SVCXPRT *xprt) Before an RPC service transport handle is destroyed, it should unregister itself with the RPC service package. This routine modifies the global variable _s_v_c__f_d_s. Service implementors usually do not need this routine. SSSSEEEEEEEE AAAALLLLSSSSOOOO xdr(3R), _I_R_I_X _N_e_t_w_o_r_k _P_r_o_g_r_a_m_m_i_n_g _G_u_i_d_e. PPPPaaaaggggeeee 11118888